﻿var editinfo = {
    feed: 290,
    init: function (index, obj) {
        $("#inputBox").find(".hover").removeClass("hover");
        $(obj).addClass("hover");
        var scale = index * editinfo.feed;
        //$("#showAD").attr("style", "top:-" + scale + "px;position:absolute;");
        $("#showAD").animate({ top: '-' + scale + 'px' }, "slow");
        if ($(obj).val() == $(obj).attr("default")) {
            $(obj).val('');
        }
        
    },
    setDefault: function () {
        if (data.data) {
            var o = data.data;
            $("#aName").val(o.AName);
            $("#beginDate").val(o.BeginTime);
            $("#lastDate").val(o.EndTime);
            $("#notice").val(o.Notice);
            $("#share").val(o.Share);
            $("#pro").val(o.Probability);
        }


    },
    save: function () {
        var obj = {};
        obj.aName = $("#aName").val();
        obj.beginDate = $("#beginDate").val();
        obj.endDate = $("#lastDate").val();
        obj.notice = $("#notice").val();
        obj.share = $("#share").val();
        obj.pro = $("#pro").val();
        //保存内容
        $.ajax({
            type: "POST",
            url: "handler/AdminHandler.ashx?action=addRoller",
            data: obj,
            dataType: 'json',
            success: function (msg) {
                rel = msg.rel;
                if (msg.rel >= 0) {
                    alert("操作成功");
                    location.href = "SetGift.aspx";
                }
                else {
                    alert("数据有错，请检查");
                }
            }
        });
        //location.href = "SetGift.aspx";
    }
};


$(document).ready(function () {
    editinfo.setDefault();
    $("#btnOK").click(editinfo.save);
    $("#aName").focus();
});